---
title: "^="
root: "/v5.1"
layout: "default"
keywords: ""
description: "Swift documentation for '^='"
---

<div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout Int, rhs: Int)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout Int16, rhs: Int16)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout Int32, rhs: Int32)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout Int64, rhs: Int64)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout Int8, rhs: Int8)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout UInt, rhs: UInt)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout UInt16, rhs: UInt16)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout UInt32, rhs: UInt32)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout UInt64, rhs: UInt64)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div><div class="intro-declaration"><code class="language-swift">func ^=(lhs:rhs:)(lhs: inout UInt8, rhs: UInt8)</code></div><div class="discussion comment"><p>Stores the result of performing a bitwise XOR operation on the two given
values in the left-hand-side variable.
</p>
<p>A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to <code>1</code> where <em>one or the other but not
both</em> of its arguments had that bit set to <code>1</code>. For example:</p>
<pre><code class="language-swift">var x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
x ^= y                    // 0b00001011
</code></pre>
</div>